package com.cql.controller;

/**
 * 接口无法被注入到spring中，因此必须借用一个controller
 */

import com.cql.pojo.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
public class TestController {

    @Qualifier("aa")
    @Autowired
    InstanceClient instanceClient;

    @RequestMapping("/haha")
    public String haha() {
        System.out.println("12");
        return instanceClient.sayHello("aa");
    }

    @RequestMapping("/xixi")
    public String xixi(@RequestBody Person param) {
        System.out.println(param.getName());
        return instanceClient.getPerson(param);
    }

    @PostMapping(value = "/cql/fileUpload", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String gg(@RequestPart(value = "file")MultipartFile file) {
        System.out.println(file.getOriginalFilename());
        return instanceClient.fileUpload(file);
    }

}
